package com.neusoft;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DemoDate {

	public static void main(String[] args) {
		
		System.out.println(new Date());
		System.out.println(new Date().getTime());
		/*
		 * 创建一个日期格式化对象
		 * SimpleDateFormat sdf = new SimpleDateFormat("日期格式:yyyy-MM-dd hh:mm:ss")
		 * 字符串转日期:  Date d=sdf.parse(String s)
		 * 日期转字符串:	String s = sdf.format(Date d)
		 */
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		
		String format = sdf.format(new Date());
		
		System.out.println(format);
		
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd");
		String date = "2020/9/16";
		try {
			System.out.println(sdf1.parse(date));
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
